{include file='public/header'/}
<main class="lyear-layout-content">
    <div class="container-fluid p-t-15">
        <div class="row">
            <div class="col-lg-12">
                <div class="card">
                    <header class="card-header">
                        <div class="card-title">卡密列表</div>
                    </header>
                    <div class="card-body">
                        <p></p>
                        <div id="toolbar" class="toolbar-btn-action">
                            <button id="btn_edit" type="button" onclick="qstatus()" class="btn btn-success m-r-5">
                                <span class="mdi mdi-check" aria-hidden="true"></span>启用
                            </button>
                            <button id="btn_edit" type="button" onclick="jstatus()" class="btn btn-warning m-r-5">
                                <span class="mdi mdi-block-helper" aria-hidden="true"></span>禁用
                            </button>
                            <button id="btn_delete" type="button" onclick="del()" class="btn btn-danger">
                                <span class="mdi mdi-window-close" aria-hidden="true"></span>删除
                            </button>
                        </div>
                        <div class="callout callout-danger mb-3">-1为永久卡密 操作人员如显示数字则为代理ID</div>
                        <div class="card-body">
                            <div class="table-responsive">
                                <table class="table table-bordered">
                                    <thead>
                                        <tr>
                                            <th>
                                                <div class="custom-control custom-checkbox">
                                                    <input type="checkbox" class="custom-control-input" id="check-all">
                                                    <label class="custom-control-label" for="check-all"></label>
                                                </div>
                                            </th>
                                            <th>ID编号</th>
                                            <th>卡密</th>
                                            <th>项目ID</th>
                                            <th>卡密面值</th>
                                            <th>开始时间</th>
                                            <th>结束时间</th>
                                            <th>添加时间</th>
                                            <th>设备标识</th>
                                            <th>操作人员</th>
                                            <th>状态</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        {volist name='list' id='code'}
                                        <tr>
                                            <td>
                                                <div class="custom-control custom-checkbox">
                                                    <input type="checkbox" class="custom-control-input ids" name="ids[]"
                                                        value="{$code.id}" id="ids-{$code.id}">
                                                    <label class="custom-control-label" for="ids-{$code.id}"></label>
                                                </div>
                                            </td>
                                            <td>{$code.id}</td>
                                            <td>{$code.kami}</td>
                                            <td>{$code.pid}</td>
                                            <td>{$code.value}</td>
                                            <td>{$code.use_time}</td>
                                            <td>{$code.end_time}</td>
                                            <td>{$code.time}</td>
                                            <td>{$code.mac}</td>
                                            <td>{$code.operator}</td>
                                            <td>{if $code.status == 'y'}正常{else}禁用{/if}</td>
                                        </tr>
                                        {/volist}
                                    </tbody>
                                </table>
                            </div>
                            {$page|raw}
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</main>


{include file='public/footer'/}
<script type="text/javascript" src="/static/js/jquery-confirm/jquery-confirm.min.js"></script>
<script type="text/javascript" src="/static/js/bootstrap-table/bootstrap-table.min.js"></script>
<script type="text/javascript" src="/static/js/bootstrap-table/locale/bootstrap-table-zh-CN.min.js"></script>
<script type="text/javascript">
    function del() {
        var id_array = new Array();
        $("input[name='ids[]']:checked").each(function () {
            id_array.push($(this).val());
        });
        var url = window.location.href;
        let t = window.jQuery;
        if (id_array.length <= 0) {
            showNotify('请选择数据', 'danger');
            return false;
        }
        $("#qstatus").attr("disabled", true).css("pointer-events", "none");
        console.log(id_array);
        $.ajax({
            cache: false,
            type: "POST",
            url: "scode/del",
            data: {
                id: id_array
            },
            dataType: 'json',
            success: function (data) {
                if (data.code == 200) {
                    showNotify(data.msg, 'success');
                } else {
                    showNotify(data.msg, 'danger');
                }
                // window.setTimeout("window.location='" + url + "'", 1000);
            }
        });
        return false;
    }
    function qstatus() {
        var id_array = new Array();
        $("input[name='ids[]']:checked").each(function () {
            id_array.push($(this).val());
        });
        var url = window.location.href;
        let t = window.jQuery;
        if (id_array.length <= 0) {
            showNotify('请选择数据', 'danger');
            return false;
        }
        $("#qstatus").attr("disabled", true).css("pointer-events", "none");
        console.log(id_array);
        $.ajax({
            cache: false,
            type: "POST",
            url: "scode/qstatus",
            data: {
                id: id_array
            },
            dataType: 'json',
            success: function (data) {
                if (data.code == 200) {
                    showNotify(data.msg, 'success');
                } else {
                    showNotify(data.msg, 'danger');
                }
                // window.setTimeout("window.location='" + url + "'", 1000);
            }
        });
        return false;
    }
    function jstatus() {
        var id_array = new Array();
        $("input[name='ids[]']:checked").each(function () {
            id_array.push($(this).val());
        });
        var url = window.location.href;
        let t = window.jQuery;
        if (id_array.length <= 0) {
            showNotify('请选择数据', 'danger');
            return false;
        }
        $("#qstatus").attr("disabled", true).css("pointer-events", "none");
        console.log(id_array);
        $.ajax({
            cache: false,
            type: "POST",
            url: "scode/jstatus",
            data: {
                id: id_array
            },
            dataType: 'json',
            success: function (data) {
                if (data.code == 200) {
                    showNotify(data.msg, 'success');
                } else {
                    showNotify(data.msg, 'danger');
                }
                // window.setTimeout("window.location='" + url + "'", 1000);
            }
        });
        return false;
    }

</script>